# https://leetcode.cn/problems/count-the-number-of-special-characters-i/description/

from collections import defaultdict
class Solution:
    def numberOfSpecialChars(self, word: str) -> int:
        diff = ord('A') - ord('a')
        r = defaultdict(set)
        ans = 0
        for x in word:
            r[x.lower()].add(x)
        for x in r.values():
            if len(x) == 2:
                ans += 1
        return ans
